﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using vite_entity.Entities;

namespace vite_entity.EntityTypeConfig
{
    public class SysLog_TypeConfig : IEntityTypeConfiguration<SysLog>
    {
        public void Configure(EntityTypeBuilder<SysLog> entity)
        {
            entity.HasKey(e => e.Id).HasName("PRIMARY");

            entity
                .ToTable("sys_log", tb => tb.HasComment("系统日志表"))
                .UseCollation("utf8mb4_general_ci");

            entity.Property(e => e.Id)
                .HasComment("主键")
                .HasColumnName("id");
            entity.Property(e => e.Browser)
                .HasMaxLength(100)
                .HasComment("浏览器")
                .HasColumnName("browser");
            entity.Property(e => e.BrowserVersion)
                .HasMaxLength(100)
                .HasComment("浏览器版本")
                .HasColumnName("browser_version");
            entity.Property(e => e.City)
                .HasMaxLength(100)
                .HasComment("城市")
                .HasColumnName("city");
            entity.Property(e => e.Content)
                .HasMaxLength(255)
                .HasComment("日志内容")
                .HasColumnName("content");
            entity.Property(e => e.CreateBy)
                .HasComment("创建人ID")
                .HasColumnName("create_by");
            entity.Property(e => e.CreateTime)
                .HasComment("创建时间")
                .HasColumnType("datetime")
                .HasColumnName("create_time");
            entity.Property(e => e.ExecutionTime)
                .HasComment("执行时间(ms)")
                .HasColumnName("execution_time");
            entity.Property(e => e.Ip)
                .HasMaxLength(45)
                .HasComment("IP地址")
                .HasColumnName("ip");
            entity.Property(e => e.IsDeleted)
                .HasComment("逻辑删除标识(1-已删除 0-未删除)")
                .HasColumnName("is_deleted");
            entity.Property(e => e.Module)
                .HasComment("日志模块")
                .HasColumnType("enum('LOGIN','USER','ROLE','DEPT','MENU','DICT','OTHER')")
                .HasColumnName("module");
            entity.Property(e => e.Os)
                .HasMaxLength(100)
                .HasComment("终端系统")
                .HasColumnName("os");
            entity.Property(e => e.Province)
                .HasMaxLength(100)
                .HasComment("省份")
                .HasColumnName("province");
            entity.Property(e => e.RequestUri)
                .HasMaxLength(255)
                .HasComment("请求路径")
                .HasColumnName("request_uri");
        }
    }
}
